package com.vic.sb36.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.vic.sb36.entity.User;
import com.vic.sb36.mapper.UserMapper;
import com.vic.sb36.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author victor
 * @since 2022-07-05
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Override
    public User findById(Long id) {
        return this.getById(id);
    }

    @Override
    public void updateName(Long id, String name) {
        LambdaUpdateWrapper<User> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper
                .set(User::getName, name)
                .eq(User::getId, id);
        boolean update = this.update(updateWrapper);
    }

    @Override
    public void updateRemark(Long id, String remark) {
        LambdaUpdateWrapper<User> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper
                .set(User::getRemark, remark)
                .eq(User::getId, id);
        boolean update = this.update(updateWrapper);
    }


}
